package com.example.demo.Route.Consumer;

import com.example.demo.Fanout.Consumer.FanoutConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

//路由模式
@Component
public class RouteConsumer {

    private static final Logger log = LoggerFactory.getLogger(RouteConsumer.class);

    //消费者1
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue,//创建临时队列
            key = {"route","info"},
            exchange = @Exchange(name = "RouteExchange")

    ))
    public void receive1(String message) {
        log.warn("Consumer1=" + message);
    }

    //消费者2
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue,//创建临时队列
            key = {"route","warn","error"},
            exchange = @Exchange(name = "RouteExchange")

    ))
    public void receive2(String message) {
        log.warn("Consumer2=" + message);
    }

}
